import re

regexExp1 = r'\d\d\d-\d\d\d-\d\d\d\d'
regexExp2 = r'(\d\d\d)-(\d\d\d)-(\d\d\d\d)'
text = 'Call me at 415-555-7973 tomorrow. 234-435-3458 is my office.'


phoneNumRegex = re.compile(regexExp1)

mo = phoneNumRegex.search(text)
print(mo.group())

phoneNumRegex1 = re.compile(regexExp1)
# 不再是Match对象，而是字符串[列表], has no groups
phoneNum = phoneNumRegex1.findall(text)
print(phoneNum)

phoneNumRegex2 = re.compile(regexExp2)
# 如果正则表达式中有分组，返回字符串[元组], has no groups
phoneNum2 = phoneNumRegex2.findall(text)
print(phoneNum2)
